package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lenovo
 */
@Api(value = "频道管理",tags = "channel",description = "频道管理API")
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    @Autowired
    AdChannelService adChannelService;

    @PostMapping("/list")
    @ApiOperation("频道列表查询")
    public ResponseResult list(@RequestBody ChannelDto channelDto){
        return adChannelService.list(channelDto);
    }

    @PostMapping("/save")
    @ApiOperation("保存频道列表")
    public ResponseResult save(@RequestBody AdChannel adChannel){
        return adChannelService.insert(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return adChannelService.update(adChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id")Integer id){
        return adChannelService.delete(id);
    }
}
